<?php

class Application_Model_Classsubject
{

  protected $_dbTable;


    public function getdbTable() {
         if (null === $this->_dbTable) {
            $this->setDbTable('Application_Model_DbTable_Classsubject');
        }
        return $this->_dbTable;
    }

    public function setdbTable($dbTable) {
        if (is_string($dbTable)) {
            $dbTable = new $dbTable();
        }
        if (!$dbTable instanceof Zend_Db_Table_Abstract) {
            throw new Exception('Invalid table data gateway provided');
        }
        $this->_dbTable = $dbTable;
        return $this;
    }

    public function save($data)
    {
        return $this->getdbTable()->insert($data);
    }
  
  	/*
  	 * 
  	 *  Retrives all class existing in the school
  	 */
    public function fetchAll($classid = 0)
    {
    	$where =array();
    	if($classid > 0)
    	{
    		$where = array('class_id = ?' =>$classid );
    	}
    	return $this->getdbTable()->fetchAll($where);
    }


}

